package com.ct.logs.responsity;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ct.logs.mapper.SysLogMapper;
import com.ct.logs.orm.SysLog;
import com.ct.repository.commons.BaseServiceImpl;
import com.ct.utils.threadlocal.UserThreadLocal;
import org.springframework.stereotype.Repository;

/**
 * <p>
 * 系统日志 Mapper 接口
 * </p>
 *
 * @author Auto Generator
 * @since 2023-08-17
 */
@Repository
public class SysLogResponsityImpl extends BaseServiceImpl<SysLogMapper,SysLog> implements ISysLogResponsity {

    @Override
    public SysLog countSystemIp(String ip,String method){
        LambdaQueryWrapper<SysLog> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(SysLog::getRequestIp,ip);
        lambdaQueryWrapper.eq(SysLog::getMethod,method);
        lambdaQueryWrapper.eq(SysLog::getSystemId, UserThreadLocal.get().getSystemId());
        lambdaQueryWrapper.apply("DATE(create_time) = CURDATE()");
        return this.getOne(lambdaQueryWrapper);
    }
}
